package com.ruoyi.lvlian.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.lvlian.domain.BusinessLicenseInfoLabel;
import com.ruoyi.lvlian.dto.BusinessLicenseInfoDto;
import com.ruoyi.lvlian.vo.CameraVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.lvlian.domain.Camera;
import com.ruoyi.lvlian.service.ICameraService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 摄像头Controller
 *
 * @author lvlian
 * @date 2025-04-24
 */
@Api(value = "摄像头", tags = "摄像头Controller")
@RestController
@RequestMapping("/camera")
public class CameraController extends BaseController {
    @Autowired
    private ICameraService cameraService;

    /**
     * 查询摄像头列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Camera camera) {
        startPage();
        List<Camera> list = cameraService.selectCameraList(camera);
        return getDataTable(list);
    }

    @ApiOperation("查询所有账本信息")
    @GetMapping("/queryCameraList")
    public TableDataInfo queryAllAccountList(@RequestParam List<String> orgCodes) {

        if (orgCodes == null || orgCodes.isEmpty()) {
            return new TableDataInfo();
        }


        startPage();
        List<CameraVo> list = cameraService.queryCameraList(orgCodes);
        return getDataTable(list);
    }


    /**
     * 获取摄像头详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(cameraService.selectCameraById(id));
    }


    /**
     * 修改摄像头
     */
    @Log(title = "摄像头", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Validated Camera camera) {
        return toAjax(cameraService.updateCamera(camera));
    }

    /**
     * 删除摄像头
     */
    @Log(title = "摄像头", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(cameraService.deleteCameraByIds(ids));
    }
}
